<?php

namespace Forms\Comment;

/**
 * 增加评论表单
 */
class AddModel extends \Forms\AbstractModel {

    /**
     * 表单字段
     * 
     * @var array
     */
    protected $_fields = array(
        'parent_id'       => array(
            'label'    => '回复的评论编号',
            'name'     => 'parent_id',
            'require'  => false,
            'default'  => 0,
            "validate" => array(
                array("type" => "int", "min" => "0", "msg" => "回复评论编号不正确")
            ),
        ),
        'source_id'       => array(
            'label'    => '来源编号',
            'name'     => 'source_id',
            'require'  => true,
            "validate" => array(
                array("type" => "string", "min" => "1", "msg" => "来源编号不正确")
            ),
        ),
        'user_id'         => array(
            'label'    => '发表评论的用户编号',
            'name'     => 'user_id',
            'require'  => true,
            "validate" => array(
                array("type" => "string", "min" => "1", "msg" => "用户编号不正确")
            ),
        ),
        'comment_content' => array(
            'label'    => '评论内容',
            'name'     => 'comment_content',
            'require'  => true,
            "validate" => array(
                array("type" => "string", "min" => "1", "max" => "1000", "msg" => "评论内容不正确")
            ),
        ),
        'add_time'        => array(
            'label'    => '增加时间',
            'name'     => 'add_time',
            'require'  => false,
            "validate" => array(
                array("type" => "string", "min" => "1", "max" => "1000", "msg" => "评论内容不正确")
            ),
        )
    );

    /**
     * 构造方法，初始化字段
     * 
     * @param array $data
     */
    public function __construct($data = array()) {
        $this->_fields['add_time']['default'] = time();
        parent::__construct($data);
    }

}
